home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / var / lib / dpkg / info / udev.preinst < prev    next >
Text File  |  2009-11-03  |  5KB  |  154 lines

  1. #!/bin/sh -e
  2. # This script can be called in the following ways:
  3. #
  4. # Before the package is installed:
  5. #    <new-preinst> install
  6. #
  7. # Before removed package is upgraded:
  8. #    <new-preinst> install <old-version>
  9. #
  10. # Before the package is upgraded:
  11. #    <new-preinst> upgrade <old-version>
  12. #
  13. #
  14. # If postrm fails during upgrade or fails on failed upgrade:
  15. #    <old-preinst> abort-upgrade <new-version>
  16.  
  17.  
  18. # Prepare to remove a no-longer used conffile
  19. prep_rm_conffile()
  20. {
  21.     CONFFILE="$1"
  22.  
  23.     if [ -e "$CONFFILE" ]; then
  24.         md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  25.         old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE '{s/ obsolete$//;s/.* //;p}}\" /var/lib/dpkg/status`"
  26.         if [ "$md5sum" != "$old_md5sum" ]; then
  27.             echo "Obsolete conffile $CONFFILE has been modified by you, renaming to .dpkg-bak"
  28.             mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
  29.     else
  30.         mv -f "$CONFFILE" "$CONFFILE".dpkg-obsolete
  31.     fi
  32.     fi
  33. }
  34.  
  35. # Prepare to move a conffile without triggering a dpkg question
  36. prep_mv_conffile() {
  37.     CONFFILE="$1"
  38.  
  39.     if [ -e "$CONFFILE" ]; then
  40.         md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  41.         old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE '{s/ obsolete$//;s/.* //;p}}\" /var/lib/dpkg/status`"
  42.         if [ "$md5sum" = "$old_md5sum" ]; then
  43.             mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
  44.     else
  45.             mv -f "$CONFFILE" "$CONFFILE".dpkg-moving
  46.         fi
  47.     fi
  48. }
  49.  
  50.  
  51. # Disable udevadm from being run during an upgrade
  52. disable_udevadm()
  53. {
  54.     dpkg-divert --local --rename --divert /sbin/udevadm.upgrade \
  55.             --add /sbin/udevadm
  56.  
  57.     cat <<'UDEVADM' > /sbin/udevadm
  58. #!/bin/sh
  59.  
  60. if [ "${0##*/}" = "udevtrigger" ] || [ "$1" = "trigger" ]; then
  61.     echo "udevadm trigger is not permitted while udev is unconfigured." 1>&2
  62.     exit 1
  63. fi
  64.  
  65. if [ "${0##*/}" = "udevsettle" ] || [ "$1" = "settle" ]; then
  66.     echo "udevadm settle is not permitted while udev is unconfigured." 1>&2
  67.     exit 1
  68. fi
  69.  
  70. exec /bin/bash -c "exec -a \"\$0\" /sbin/udevadm.upgrade \"\$@\"" "$0" "$@"
  71. UDEVADM
  72.     chmod +x /sbin/udevadm
  73. }
  74.  
  75.  
  76. # Prepare to remove Ubuntu rules in favour of upstream ones
  77. prep_rm_ubuntu_rules()
  78. {
  79.     prep_rm_conffile /etc/udev/rules.d/05-options.rules
  80.     prep_rm_conffile /etc/udev/rules.d/05-udev-early.rules
  81.     prep_rm_conffile /etc/udev/rules.d/20-names.rules
  82.     prep_rm_conffile /etc/udev/rules.d/30-cdrom_id.rules
  83.     prep_rm_conffile /etc/udev/rules.d/40-basic-permissions.rules
  84.     prep_rm_conffile /etc/udev/rules.d/40-permissions.rules
  85.     prep_rm_conffile /etc/udev/rules.d/60-persistent-input.rules
  86.     prep_rm_conffile /etc/udev/rules.d/60-persistent-storage-tape.rules
  87.     prep_rm_conffile /etc/udev/rules.d/60-persistent-storage.rules
  88.     prep_rm_conffile /etc/udev/rules.d/60-symlinks.rules
  89.     prep_rm_conffile /etc/udev/rules.d/61-persistent-storage-edd.rules
  90.     prep_rm_conffile /etc/udev/rules.d/65-id-type.rules
  91.     prep_rm_conffile /etc/udev/rules.d/66-persistent-storage-edd.rules
  92.     prep_rm_conffile /etc/udev/rules.d/75-cd-aliases-generator.rules
  93.     prep_rm_conffile /etc/udev/rules.d/75-persistent-net-generator.rules
  94.     prep_rm_conffile /etc/udev/rules.d/80-programs.rules
  95.     prep_rm_conffile /etc/udev/rules.d/90-modprobe.rules
  96.     prep_rm_conffile /etc/udev/rules.d/95-udev-late.rules
  97. }
  98.  
  99.  
  100. case "$1" in
  101.     install|upgrade)
  102.         disable_udevadm
  103.  
  104.     # Upgrade from intrepid
  105.     if dpkg --compare-versions "$2" lt "136-4"; then
  106.         prep_rm_ubuntu_rules
  107.     fi
  108.  
  109.     # Upgrade from jaunty
  110.     if dpkg --compare-versions "$2" lt "143-3"; then
  111.         prep_rm_conffile /etc/scsi_id.config
  112.     fi
  113.     ;;
  114.  
  115.     abort-upgrade)
  116.     ;;
  117.  
  118.     *)
  119.     echo "$0 called with unknown argument \`$1'" 1>&2
  120.     exit 1
  121.     ;;
  122. esac
  123.  
  124. # Automatically added by dh_installinit
  125. if [ "$1" = install ] || [ "$1" = upgrade ]; then
  126.     if [ -e "/etc/init.d/udev" ] && [ ! -L "/etc/init.d/udev" ]; then
  127.         if [ "`md5sum \"/etc/init.d/udev\" | sed -e \"s/ .*//\"`" != \
  128.              "`dpkg-query -W -f='${Conffiles}' udev | sed -n -e \"\\\\' /etc/init.d/udev '{s/ obsolete$//;s/.* //p}\"`" ]
  129.         then
  130.             echo "Obsolete conffile /etc/init.d/udev has been modified by you, renaming to .dpkg-bak"
  131.             mv -f "/etc/init.d/udev" "/etc/init.d/udev.dpkg-bak"
  132.         else
  133.             rm -f "/etc/init.d/udev"
  134.         fi
  135.     fi
  136. fi
  137. # End automatically added section
  138. # Automatically added by dh_installinit
  139. if [ "$1" = install ] || [ "$1" = upgrade ]; then
  140.     if [ -e "/etc/init.d/udev-finish" ] && [ ! -L "/etc/init.d/udev-finish" ]; then
  141.         if [ "`md5sum \"/etc/init.d/udev-finish\" | sed -e \"s/ .*//\"`" != \
  142.              "`dpkg-query -W -f='${Conffiles}' udev | sed -n -e \"\\\\' /etc/init.d/udev-finish '{s/ obsolete$//;s/.* //p}\"`" ]
  143.         then
  144.             echo "Obsolete conffile /etc/init.d/udev-finish has been modified by you, renaming to .dpkg-bak"
  145.             mv -f "/etc/init.d/udev-finish" "/etc/init.d/udev-finish.dpkg-bak"
  146.         else
  147.             rm -f "/etc/init.d/udev-finish"
  148.         fi
  149.     fi
  150. fi
  151. # End automatically added section
  152.  
  153. exit 0
  154.